//var newArray = arr.filter(callback(element[, index[, array]])[, thisArg])

Array.prototype.filter1=function(callback,thisArr){
    if((typeof callback!=='function')||!this){
        throw new TypeError();
    }
    const res=[];
    var obj=Object(this);
    let len=obj.length;
    for(let i=0;i<len;i++){
        if(i in obj){
            if(callback.call(thisArr,obj[i],i,obj)){
                res.push(obj[i])
            }
        }
    }
    return res;
}
let arr=[-1,2,3,-2];
var res=arr.filter1(item=>item>0)
console.log(res);